package java.set;

import java.util.*;
import java.util.stream.Collectors;

public class SetDemo {
    public static void main(String[] args) {
        String[] credentials = {"aa", "bb", "cc"};
        System.out.println("输出：" + sanitizeCredentials(credentials));
    }

    private static Set<String> sanitizeCredentials(final String[] credentials) {
        if (credentials != null && credentials.length > 0) {
            return Arrays.stream(credentials)
                    .filter(Objects::nonNull)
                    .collect(Collectors.toCollection(LinkedHashSet::new));
        }
        return new HashSet<>(0);
    }
}
